using System;
using System.ComponentModel;
using System.Xml.Serialization;

namespace com.exceptionalsoftware.spacetime.KML
{
	[Serializable()]
    [XmlType(TypeName = "IconStyleType")]
	public class IconStyle : ColorStyle
	{
        private float scaleField, headingField;
        private IconStyleIcon iconField;
        private Vec2Type hotSpotField;
        
        public IconStyle()
		{
            this.scaleField = 1F;
            this.headingField = 0F;
		}

        [XmlElement(ElementName = "scale", DataType = "float")]
        public float Scale
        {
            get { return this.scaleField; }
            set { this.scaleField = value; }
        }

        [XmlElement(ElementName = "heading", DataType = "float")]
        [DefaultValue(typeof(float), "0")]
        public float Heading
        {
            get { return this.headingField; }
            set { this.headingField = value; }
        }

        [XmlElement(ElementName = "Icon", Type = typeof(IconStyleIcon))]
        public IconStyleIcon Icon
        {
            get { return this.iconField; }
            set { this.iconField = value; }
        }

        [XmlElement(ElementName = "hotSpot", Type = typeof(Vec2Type))]
        public Vec2Type HotSpot
        {
            get { return this.hotSpotField; }
            set { this.hotSpotField = value; }
        }
    }
   
    [Serializable()]
    [XmlType(TypeName = "IconStyleIconType")]
    public class IconStyleIcon : ObjectType
    {
        private string hrefField;

        [XmlElement(ElementName = "href", DataType = "anyURI")]
        public string href
        {
            get { return this.hrefField; }
            set { this.hrefField = value; }
        }
    }

    [XmlType(TypeName = "vec2Type")]
    public class Vec2Type : ObjectType
    {
        private double xField, yField;
        private UnitsEnum xUnitsField, yUnitsField;

        public Vec2Type()
        {
            this.xField = 1.0;
            this.yField = 1.0;
            this.xUnitsField = UnitsEnum.Fraction;
            this.yUnitsField = UnitsEnum.Fraction;
        }
        //[DefaultValue(1.0)]
        //[DefaultValue(1.0)]
        //[System.ComponentModel.DefaultValueAttribute(UnitsEnum.Fraction)]
        //[System.ComponentModel.DefaultValueAttribute(UnitsEnum.Fraction)]

        [XmlAttribute(AttributeName = "x", DataType = "double")]
        public double x
        {
            get { return this.xField; }
            set { this.xField = value; }
        }

        [XmlAttribute(AttributeName = "y", DataType = "double")]
        public double y
        {
            get { return this.yField; }
            set { this.yField = value; }
        }

        [System.Xml.Serialization.XmlAttributeAttribute()]
        public UnitsEnum xunits
        {
            get { return this.xUnitsField; }
            set { this.xUnitsField = value; }
        }

        [System.Xml.Serialization.XmlAttributeAttribute()]
        public UnitsEnum yunits
        {
            get { return this.yUnitsField; }
            set { this.yUnitsField = value; }
        }    
    }

    //public enum UnitsEnum
    //{

    //    /// <remarks/>
    //    Fraction,

    //    /// <remarks/>
    //    Pixels,

    //    /// <remarks/>
    //    InsetPixels,
    //}

    [XmlType(TypeName = "unitsEnum")]
    public enum UnitsEnum
    {
        [XmlEnum(Name = "fraction")]
        Fraction,

        [XmlEnum(Name = "pixels")]
        Pixels,

        [XmlEnum(Name = "insetPixels")]
        InsetPixels
    }
}